//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "math\fn_getSlope.sqf"
#include <tmf_constants.h>
#include <tmf_macros.h>

TRACE_1("Start",_this);
TMFPROFILERSTART;

private ["_position", "_radius", "_centerHeight", "_height", "_direction", "_count"];
DEFAULT_PARAM(_position,0,ARR_3(0,0,0));
DEFAULT_PARAM(_radius,1,5);
if (_radius <= 0) then { _radius = 5};
if (isNil QGVAR(SLOPE_OBJECT)) then {GVAR(SLOPE_OBJECT) = "Land_HelipadEmpty_F" createVehicleLocal [0,0,0]};
	
GVAR(SLOPE_OBJECT) setPos _position;
_centerHeight = getPosASL GVAR(SLOPE_OBJECT) select 2;
_height = 0;_direction = 0;
for "_count" from 0 to 7 do {
	GVAR(SLOPE_OBJECT) setPos [(_position select 0)+((sin _direction)*_radius),(_position select 1)+((cos _direction)*_radius),0];
	_direction = _direction + 45;
	_height = _height + abs (_centerHeight - (getPosASL GVAR(SLOPE_OBJECT) select 2));
};

TRACE("End");
TMFPROFILERSTOP;
_height / 8